<template>
  <HModal @cancel="close" @ok="handleOK"
          :width="1000" :height="600" title="选择菜单" :visible="visible">
    <FormMenuSelector v-model="formMenuId" @update:title="t => formMenuTitle = t"/>
  </HModal>
</template>
<script>
import HModal from '@comp/hhd/HModal/HModal.vue';
import FormMenuSelector from '@comp/hhd/design/FormMenuSelector/FormMenuSelector.vue';

export default {
  name: 'FormMenuSelectorModal',
  components: {
    FormMenuSelector,
    HModal
  },
  data() {
    return {
      formMenuId: undefined,
      formMenuTitle: undefined,
      visible: false,
    };
  },
  methods: {
    open() {
      this.visible = true;
      this.formMenuTitle = undefined;
      this.formMenuId = undefined;
    },
    handleOK() {
      if (!this.formMenuId) {
        this.$message.warn('请选择菜单');
        return;
      }
      this.$emit('ok', {
        formMenuId: this.formMenuId,
        formMenuTitle: this.formMenuTitle,
      });
      this.close();
    },
    close() {
      this.visible = false;
    },
  }
};
</script>